<?php

namespace app\factory;



use app\factory\register\FrameRegister;
use app\factory\register\RegToolOne;
use app\factory\register\RegToolThree;
use app\factory\register\RegToolTwo;

/**
 * ClassName:仓库管理
 * @author leijunxiang
 * @time 2024/7/20
 * @auditor
 */
class WarehouseManage
{
    //仓库注册对象队列
    protected $warehouseRegisterObjList;


    public function __construct()
    {
        $this->warehouseRegisterObjList[] = new FrameRegister();
        $this->warehouseRegisterObjList[] = new RegToolOne();
        $this->warehouseRegisterObjList[] = new RegToolTwo();
        $this->warehouseRegisterObjList[] = new RegToolThree();
    }



    /**
     * 获取m层对象(对象key,类型key)
     */
    public function getModelObj($objKey, $typeKey)
    {
        $obj = null;
        if(!$this->warehouseRegisterObjList||empty($objKey)||empty($typeKey)){
            return null;
        }
        foreach ($this->warehouseRegisterObjList as $registerObj) {
            //创建M层对象(对象key)
            $obj = $registerObj->regModel($objKey, $typeKey);
            if ($obj){
                break;
            }
        }
        return $obj;
    }

    /**
     * 获取t层对象(对象key,类型key)
     */
    public function getToolObj($objKey, $typeKey)
    {
        $obj = null;
        if(!$this->warehouseRegisterObjList||empty($objKey)||empty($typeKey)){
            return null;
        }
        foreach ($this->warehouseRegisterObjList as $registerObj) {
            //创建工具对象（对象key）
            $obj = $registerObj->regTool($objKey,$typeKey);
            if ($obj){
                break;
            }
        }
        return $obj;
    }

    /**
     * 获取常驻M层对象(对象key,类型key)
     */
    public function getResidentModelObj($objKey, $typeKey)
    {
        $obj = null;
        if(!$this->warehouseRegisterObjList||empty($objKey)||empty($typeKey)){
            return null;
        }
        foreach ($this->warehouseRegisterObjList as $registerObj) {
            //创建常驻M层对象(对象key)
            $obj = $registerObj->regResidentModel($objKey, $typeKey);
            if ($obj){
                break;
            }
        }
        return $obj;
    }


}